<?php

namespace App\Kuafu\CouponExt\Enum;

use App\Kuafu\Base\Enum\BaseCodeEnum;
use App\Kuafu\Order\Enum\OrderInfoEnum;

class CouponExtEnum extends BaseCodeEnum
{
    // 优惠券类型
    const COUPON_TYPE_MONEY       = 1; // 代金券
    const COUPON_TYPE_PRODUCT     = 2; // 套餐券
    const COUPON_TYPE_GROUP_MEALS = 3; // 团餐券
    const COUPON_TYPE_TIMES_CARD  = 4; // 次卡券

    //券类型
    public const COUPON_TYPE_TEXT = [
        self::COUPON_TYPE_MONEY       => '代金券',
        self::COUPON_TYPE_PRODUCT     => '商品/套餐券',
        self::COUPON_TYPE_GROUP_MEALS => '团餐券',
        self::COUPON_TYPE_TIMES_CARD  => '次卡券',
    ];

    const COUPON_CANCEL_STATUS_1 = 1; // 可撤销
    const COUPON_CANCEL_STATUS_0 = 0; // 不可撤销
    //外部平台
    const EXT_PLATFORM_KUAFU   = 0;
    const EXT_PLATFORM_MEITUAN = 1;
    const EXT_PLATFORM_DOUYIN  = 2;
    const EXT_PLATFORM_XHS     = 3;

    public const EXT_PLATFORM_TEXT = [
        self::EXT_PLATFORM_KUAFU   => '夸父',
        self::EXT_PLATFORM_MEITUAN => '美团',
        self::EXT_PLATFORM_DOUYIN  => '抖音',
        self::EXT_PLATFORM_XHS     => '小红书',
    ];

    /**
     * 切换 EXT_PLATFORM to Order Payment 的类型
     *
     * @param int $extPlatform
     * @return int
     */
    public static function switchExtPlatform2OrderPayment(int $extPlatform): int
    {
        switch ($extPlatform) {
            case CouponExtEnum::EXT_PLATFORM_DOUYIN:
                $paymentType = OrderInfoEnum::POS_ORDER_PAYMENT_COUPON_DOUYIN;
                break;
            case CouponExtEnum::EXT_PLATFORM_XHS:
                $paymentType = OrderInfoEnum::POS_ORDER_PAYMENT_COUPON_XHS;
                break;
            case CouponExtEnum::EXT_PLATFORM_MEITUAN:
            default:
                $paymentType = OrderInfoEnum::POS_ORDER_PAYMENT_COUPON_MEITUAN;
                break;
        }

        return $paymentType;
    }

    //核销状态
    const COUPON_STATUS_DEFAULT = 0;
    const COUPON_STATUS_USED    = 1;
    const COUPON_STATUS_CANCEL  = 2;


    public const COUPON_STATUS_TEXT = [
        self::COUPON_STATUS_DEFAULT => '默认',
        self::COUPON_STATUS_USED    => '已使用',
        self::COUPON_STATUS_CANCEL  => '已撤销',
    ];


}
